package com.xunqi.util;

import java.util.Random;

/**
 * 生成ID工具类
 * 
 * @author yemei
 *
 */
public class IdGenerateUtil {
	private static final Random random = new Random();

	/**
	 * 根据时间戳13 + 4位随机数生成ID
	 * 
	 * @return
	 */
	public static long generateIdByTimeStamp() {
		long currentTime = System.currentTimeMillis();
		int randomInt4 = (int) ((Math.random() + (random.nextInt(9) + 1)) * 1000);
		return Long.valueOf(String.valueOf(currentTime) + String.valueOf(randomInt4));
	}

	public static void main(String[] args) {
		for (int i = 0; i < 100; i++) {
			System.out.println(generateIdByTimeStamp());
		}
	}
}
